package com.example.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@SpringBootTest
public class BookServiceTestCase {

    @Resource
    private IBookService bookService;

    @Test
    void testSave(){
        Book book = new Book();
        book.setType("计算机书籍");
        book.setName("C Primer Plus，5th Edition");
        book.setDescription("【美】Stephen Prata著");
        bookService.save(book);
    }

    @Test
    void testUpdate(){
        Book book = new Book();
        book.setId(14);
        book.setType("计算机书籍");
        book.setName("C Primer Plus，5th Edition~");
        book.setDescription("【美】Stephen Prata著");
        bookService.update(book);
    }

    @Test
    void testDelete(){
        bookService.delete(14);
    }

    @Test
    void testGetById(){
        Book book = bookService.getById(12);
        System.out.println(book);
    }

    @Test
    void testGetAll(){
        System.out.println(bookService.getAll());
    }

    @Test
    void testGetPage(){
        IPage<Book> page = bookService.getPage(1, 5);
        System.out.println(page.getRecords());
    }

}
